<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:pe="http://primefaces.org/ui/extensions"
                xmlns:f="http://java.sun.com/jsf/core">

    <pe:importEnum type="md.mru.frontend.utils.MainContentTypes" var="contentType"/>

    <h:outputScript>
        /* javascript function used to hide center-north page layout */
        function hideCenterNorthLayout() {
            PF('layoutWV').close('center_north');
            $('.ui-layout-resizer-north').css("display", "none");
        }
    </h:outputScript>

    <h:form id="main_menu">

        <p:menubar>

            <ui:remove><!-- menu bar items --></ui:remove>

            <p:menuitem value="Evenimente" immediate="true"
                        actionListener="#{eventAdministrationBean.initializeEventContent}" update=":main_content"
                        onclick="hideCenterNorthLayout()">
                <f:setPropertyActionListener value="#{contentType.EVENTS_CONTENT}"
                                             target="#{mainContentHandler.currentAccessedContent}"/>
            </p:menuitem>

            <p:submenu label="Utilitati">
                <p:menuitem value="Dosare" immediate="true"
                            actionListener="#{folderAdministrationBean.initializeFoldersContent}"
                            update=":main_content" onclick="hideCenterNorthLayout()">
                    <f:setPropertyActionListener value="#{contentType.FOLDERS_CONTENT}"
                                                 target="#{mainContentHandler.currentAccessedContent}"/>
                </p:menuitem>
                <p:menuitem value="Emite ordin comun" immediate="true"
                            actionListener="#{orderAdministrationBean.initializeCommonOrderContent}"
                            update=":main_content" onclick="hideCenterNorthLayout()">
                    <f:setPropertyActionListener value="#{contentType.COMMON_ORDER_CONTENT}"
                                                 target="#{mainContentHandler.currentAccessedContent}"/>
                </p:menuitem>
                <p:menuitem value="Sabloane text ordine" immediate="true"
                            actionListener="#{orderAdministrationBean.initializeOrderPatternsContent}"
                            update=":main_content" onclick="hideCenterNorthLayout()" resetValues="true">
                    <f:setPropertyActionListener value="#{contentType.ORDERS_TEMPLATES_CONTENT}"
                                                 target="#{mainContentHandler.currentAccessedContent}"/>
                </p:menuitem>
            </p:submenu>


            <p:submenu label="Administrare">
                <p:menuitem value="Etichete de sistem" immediate="true"
                            actionListener="#{systemTagAdministrationBean.initializeSystemTagsContent}"
                            update=":main_content" onclick="hideCenterNorthLayout()">
                    <f:setPropertyActionListener value="#{contentType.SYSTEM_TAGS_CONTENT}"
                                                 target="#{mainContentHandler.currentAccessedContent}"/>
                </p:menuitem>
                <p:menuitem value="Utilizatori" immediate="true"
                            actionListener="#{userAdministrationBean.initializeUsersContent}"
                            update=":main_content" onclick="hideCenterNorthLayout()">
                    <f:setPropertyActionListener value="#{contentType.USERS_CONTENT}"
                                                 target="#{mainContentHandler.currentAccessedContent}"/>
                </p:menuitem>
                <p:menuitem value="Grupuri" immediate="true"
                            actionListener="#{groupAdministrationBean.initializeGroupssContent}"
                            update=":main_content" onclick="hideCenterNorthLayout()">
                    <f:setPropertyActionListener value="#{contentType.GROUPS_CONTENT}"
                                                 target="#{mainContentHandler.currentAccessedContent}"/>
                </p:menuitem>
            </p:submenu>

            <ui:remove><!-- menu bar options --></ui:remove>

            <f:facet name="options">
                <p:commandButton id="userOptionsBtn" icon="ui-icon-triangle-1-s" type="button"/>

                <p:overlayPanel id="userOptions" for="userOptionsBtn" hideEffect="fade">
                    <h:panelGrid columns="2" style="text-align: center;">
                        <h:form>
                            <h:panelGrid columns="2">
                                <p:outputLabel value="Logat ca:"/>
                                <h:outputText value="#{authenticationBean.loginUser.user.email}"/>

                                <p:outputLabel value="Adresa de e-mail:"/>
                                <h:outputText value="#{authenticationBean.loginUser.user.email}"/>

                                <p:commandLink value="Editeaza profil"
                                               actionListener="#{administrationBean.editProfile}"
                                               oncomplete="PF('edit_user_profile_var').show()"/>

                                <p:commandLink value="Logout" immediate="true" action="#{authenticationBean.logout()}"
                                               ajax="false"/>
                                <p:commandButton type="button" value="Logout" icon="ui-icon-extlink"/>
                            </h:panelGrid>
                        </h:form>
                    </h:panelGrid>
                </p:overlayPanel>
            </f:facet>
        </p:menubar>

    </h:form>

</ui:composition>